home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / 123w20.zip / 123DEMO2.BAS next >
BASIC Source File  |  1990-11-15  |  61KB  |  1,800 lines

  1. DEFINT A-Z
  2.  
  3. '123DEMO2.BAS a demonstration program for the 123-Write version 2.0
  4. 'spreadsheet file generation library.
  5.  
  6. 'Sept 1990
  7.  
  8. 'This program really doesn't do much of anything, I wrote it as a
  9. 'test bed of all the routines in 123-Write.  The resulting worksheet
  10. 'file will be written to the current directory, unless you specify
  11. 'a full path spec at the prompt.
  12.  
  13. 'BASIC:
  14.  
  15. DECLARE FUNCTION Rand% (lowerbound%, upperbound%)
  16.  
  17. DECLARE SUB ColFeed ()
  18. DECLARE SUB Page1 ()
  19. DECLARE SUB Page2 ()
  20. DECLARE SUB Page3 ()
  21. DECLARE SUB Page4 ()
  22. DECLARE SUB Page5 ()
  23. DECLARE SUB Page6 ()
  24. DECLARE SUB Page7 ()
  25. DECLARE SUB Page8 ()
  26. DECLARE SUB Page9 ()
  27. DECLARE SUB Page10 ()
  28. DECLARE SUB Page11 ()
  29. DECLARE SUB Page12 ()
  30. DECLARE SUB Page13 ()
  31. DECLARE SUB Page14 ()
  32. DECLARE SUB Page15 ()
  33. DECLARE SUB Page16 ()
  34. DECLARE SUB Page17 ()
  35. DECLARE SUB Page18 ()
  36. DECLARE SUB Page19 ()
  37. DECLARE SUB Page20 ()
  38. DECLARE SUB WriteCol (count%)
  39. DECLARE SUB WriteRanges ()
  40.  
  41. '123-Write include file:  123W20.BI
  42. 'Declares for all the 123-Write Routines.
  43.  
  44. DECLARE FUNCTION lCol% (col$)
  45.  
  46. DECLARE SUB lBoolean (col1%, row1%, col2%, row2%, operation%)
  47. DECLARE SUB lCellFunction (dSeg%, dOfs%)
  48. DECLARE SUB lCellMath (col1%, row1%, col2%, row2%, oper%)
  49. DECLARE SUB lClose
  50. DECLARE SUB lColFunction (startRow%, endRow%, oper%)
  51. DECLARE SUB lConstMath (col%, row%, constVal#, oper%)
  52. DECLARE SUB lDate (dat$)
  53. DECLARE SUB lDown (count%)
  54. DECLARE SUB lFileAppend (filename$, ecode%)
  55. DECLARE SUB lFileOpen (filename$, errCode%)
  56. DECLARE SUB lGetLoc (whatCol%, whatRow%)
  57. DECLARE SUB lGlobal (item%, switch%)
  58. DECLARE SUB lHideCol (col%, writeFlag%)
  59. DECLARE SUB lLeft (count%)
  60. DECLARE SUB lLineFeed
  61. DECLARE SUB lLink (fileSpecRange$)
  62. DECLARE SUB lMultiCellMath (dSeg%, dOfs%)
  63. DECLARE SUB lPrintBorders (rulc%, rulr%, rlrc%, rlrr%, culc%, culr%, clrc%, clrr%)
  64. DECLARE SUB lPrintMargins (lm%, rm%, tm%, bm%, pageLen%)
  65. DECLARE SUB lPrintRange (ulc%, ulr%, lrc%, lrr%)
  66. DECLARE SUB lPrintSetup (setup$)
  67. DECLARE SUB lPrintTitle (title$, header%)
  68. DECLARE SUB lRange (rangeName$, ulc%, ulr%, lrc%, lrr%)
  69. DECLARE SUB lRight (count%)
  70. DECLARE SUB lRowFunction (startCol%, endCol%, oper%)
  71. DECLARE SUB lSetCellForm (formatCode%, decimals%)
  72. DECLARE SUB lSetCols (colWidths%())
  73. DECLARE SUB lSetCol (col%, colWidth%)
  74. DECLARE SUB lSetDateForm (format%, protect%)
  75. DECLARE SUB lSetLoc (newCol%, newRow%)
  76. DECLARE SUB lSetStrForm (formatCode%)
  77. DECLARE SUB lSetTimeForm (format%, protect%)
  78. DECLARE SUB lSortKey (primry%, ulc%, ulr%, lrc%, lrr%, ascnd%)
  79. DECLARE SUB lSortRange (ulc%, ulr%, lrc%, lrr%)
  80. DECLARE SUB lTime (timeStr$)
  81. DECLARE SUB lTimeNow
  82. DECLARE SUB lToday
  83. DECLARE SUB lUp (count%)
  84. DECLARE SUB lWriteErr
  85. DECLARE SUB lWriteInt (integerVal%, errCode%)
  86. DECLARE SUB lWriteNum (doubleVal#, errCode%)
  87. DECLARE SUB lWriteStr (dat$, errCode%)
  88.  
  89. '==================================================================
  90. '
  91. '  Some frequently used co-ordinates might be handy.  I'm mixing
  92. '  CONSTs and variables for testing purposes only.
  93. '
  94. '==================================================================
  95.  
  96. CONST Page1Col = 0            'The top left corner of page 1, cell A1
  97. CONST Page1Row = 0
  98. CONST Page2Col = 8            'Cell I1, the top left corner of page 2
  99. CONST Page2Row = 0
  100. CONST Page5Col = 0            'Cell A41, the top left corner of page 5
  101. CONST Page5Row = 40
  102. CONST Page6Col = 0            'Cell A61, the top left corner of page 6
  103. CONST Page6Row = 60
  104. CONST Page7Col = 8            'Cell I21, the top left corner of page 7
  105. CONST Page7Row = 20
  106. CONST Page8Col = 8            'Cell I41, the top left corner of page 8
  107. CONST Page8Row = 40
  108. CONST Page9Col = 0            'Cell A81, the top left corner of page 9
  109. CONST Page9Row = 80
  110. CONST Page10Col = 0           'Cell A100, the top left corner of page 10
  111. CONST Page10Row = 100
  112. CONST Page11Col = 8           'Cell I61, the top left corner of page 11
  113. CONST Page11Row = 60
  114. CONST Page12Col = 8           'Cell I81, the top left corner of page 12
  115. CONST Page12Row = 80
  116. CONST Page13Col = 0           'Cell A121, the top left corner of page 13
  117. CONST Page13Row = 120
  118. CONST Page14Col = 15          'Cell P21, the top left corner of page 14
  119. CONST Page14Row = 20
  120. CONST Page15Col = 15          'Cell P41, the top left corner of page 15
  121. CONST Page15Row = 40
  122. CONST Page16Col = 15          'Cell P61, the top left corner of page 16
  123. CONST Page16Row = 60
  124. CONST Page17Col = 15          'Cell P81, the top left corner of page 17
  125. CONST Page17Row = 80
  126. CONST Page18Col = 15          'Cell P101, the top left corner of page 18
  127. CONST Page18Row = 100
  128. CONST Page19Col = 15          'Cell P121, the top left corner of page 19
  129. CONST Page19Row = 120
  130. CONST Page20Col = 8           'Cell I101, the top left corner of page 19
  131. CONST Page20Row = 100
  132. CONST fixed = 1               'These are cell format equates, it's easier
  133. CONST currcy = 3              'to read (fixed,2) than (1,2) I think.
  134. CONST percent = 4
  135. CONST comma = 5
  136. CONST special = 6             'A hidden cell format is in the special category
  137. CONST hidden = 6              'so these two equates will kill 2 birds...
  138.  
  139. TYPE FunctionCallType        'This guy can be used for any?? @function
  140.     fCode   AS INTEGER       'call.  I type'd it out to the maximum number
  141.     col1    AS INTEGER       'of elements that any of the Lotus @functions
  142.     row1    AS INTEGER       'will need. I think.  We'll find out if I'm
  143.     col2    AS INTEGER       'right on page 5, so stay tuned.
  144.     row2    AS INTEGER
  145.     col3    AS INTEGER
  146.     row3    AS INTEGER
  147.     col4    AS INTEGER
  148.     row4    AS INTEGER
  149.     col5    AS INTEGER
  150.     row5    AS INTEGER
  151. END TYPE
  152.  
  153. 'A BASIC 7.0+ version of the above would look like:
  154. '
  155. 'TYPE ColRowType
  156. '    col    as INTEGER
  157. '    row    as INTEGER
  158. 'END TYPE
  159. '
  160. 'TYPE FunctionCallType
  161. '   fCode           AS INTEGER
  162. '   coOrds(1 to 5)  as ColRowType
  163. 'END TYPE
  164.  
  165. TYPE MultiMathType
  166.     col    AS INTEGER
  167.     row    AS INTEGER
  168.     opr    AS INTEGER
  169. END TYPE
  170.  
  171.     DIM SHARED f AS FunctionCallType
  172.     DIM SHARED lVersion AS INTEGER
  173.     DIM SHARED errCode AS INTEGER
  174.  
  175.     ON ERROR GOTO ErrorTrap
  176.     RANDOMIZE (TIMER)                    'Just to vary things a little....
  177.  
  178. '==================================================================
  179. '
  180. '  First step, get a file name, and open the spreadsheet file.
  181. '  If an extension is not supplied with the filename, 123-Write
  182. '  will use the "WKS" extension.
  183. '
  184. '==================================================================
  185.  
  186.     KEY 1, "DEMO.WKS" + CHR$(13)     'I've run this so many times, it's easier
  187.     KEY 2, "DEMO.WK1" + CHR$(13)     'to hit 1 key for the same file over and
  188.     CLS                              'over!
  189.  
  190.     PRINT "123-Write version 2.0 demonstration."
  191.     PRINT "The filename you supply for the spreadsheet can be a complete"
  192.     PRINT "path spec.  If you don't supply an extension, WKS will be used."
  193.     PRINT
  194.     PRINT "If the file you specify already exists, it will be overwritten"
  195.     PRINT "by this demo."
  196.     PRINT
  197.     INPUT "File name to create: ", fileSpec$
  198.     IF fileSpec$ = "" THEN END
  199.  
  200.     PRINT
  201.     PRINT "Create a Lotus release 2.0+ compatible spreadsheet? (Y/N)"
  202.     PRINT "If you hit N, Lotus 1a (and compatibles) functions only"
  203.     PRINT "will be used."
  204.  
  205.     DO
  206.         z$ = UCASE$(INKEY$)
  207.     LOOP UNTIL z$ = "Y" OR z$ = "N"          'The lVersion variable
  208.                                              'will dictate 2.0+ files
  209.     lVersion = (z$ = "Y")
  210.  
  211.     CALL lFileOpen(fileSpec$, errCode)       'The error trap set above checks
  212.     IF errCode THEN ERROR 255                'for 255, indicating an error
  213.                                              'return from 123-Write
  214.     CALL WriteRanges                         'See the documentation for an
  215.     CALL Page1                               'explanation of the need to write
  216.     CALL Page2                               'range names early.
  217.     CALL Page3
  218.     CALL Page4
  219.     CALL Page5
  220.     CALL Page6
  221.     CALL Page7
  222.     CALL Page8
  223.     CALL Page9
  224.     CALL Page10
  225.     CALL Page11
  226.     CALL Page12
  227.     CALL Page13
  228.     CALL Page14
  229.     CALL Page15
  230.     CALL Page16
  231.  
  232.     CALL lClose                              'Closing the file at this point
  233.                                              'to illustrate the File Append
  234.     CALL lFileAppend(fileSpec$, errCode)     'routine.
  235.     IF errCode THEN ERROR 255
  236.  
  237.     CALL Page17
  238.     CALL Page18
  239.     CALL Page19
  240.     CALL Page20
  241.  
  242.     CALL lClose
  243.     END
  244.  
  245. ErrorTrap:
  246.  
  247.     IF ERR = 255 THEN
  248.         PRINT
  249.         PRINT "An error was returned by 123-Write."
  250.         PRINT "Error code:"; errCode
  251.         PRINT
  252.         CALL lClose
  253.     ELSE
  254.         PRINT
  255.         PRINT "An error was returned by BASIC."
  256.         PRINT "Error code:"; ERR
  257.         PRINT
  258.         CALL lClose
  259.     END IF
  260.  
  261.     END
  262.  
  263. '==================================================================
  264. '
  265. '  This section of data statements is used to write the intro on
  266. '  the first page of the spreadsheet.
  267. '
  268. '==================================================================
  269.  
  270. Page1Data:
  271.  
  272. DATA "123-Write version 2 demo worksheet                               Page 1"
  273. DATA " "
  274. DATA "   This spreadsheet was written as a demonstration of the routines"
  275. DATA "available in  123-Write  version 2.0.   The entire spreadsheet was"
  276. DATA "written from within BASIC."
  277. DATA " "
  278. DATA "There are a number of ranges, all named PAGE_? that show different"
  279. DATA "features of the routines in 123-Write.  You can use the: F5 [GOTO]"
  280. DATA "key, then the F3 key to select an area of interest.
  281. DATA " "
  282. DATA "Page 1      This page, which shows the String write ability."
  283. DATA "     2      Shows the cell display options that are available."
  284. DATA "     3      123-Write Date & Time routines, & their formats."
  285. DATA "     4      Boolean comparisons and operators. "
  286. DATA "     5      General, Logarithmic & Trigonometric @ Functions."
  287. DATA "     6      Statistical and Database Statistical @ Functions."
  288. DATA "     7      Financial and Accounting @ Functions."
  289. DATA "     8      Logical and error testing @ Functions."
  290. DATA "     9      Special range and miscellaneous @ Functions. "
  291. DATA "    10      MORE options!"
  292.  
  293. Page2Data:
  294.  
  295. DATA "Illustration of cell formatting possibilites."
  296. DATA "Fixed"
  297. DATA "Scient"
  298. DATA "Currency"
  299. DATA "Percent"
  300. DATA "Comma"
  301. DATA "+ / -"
  302. DATA "General"
  303. DATA "Date 1"
  304. DATA "Date 2"
  305. DATA "Date 3"
  306. DATA "Text"
  307. DATA "Hidden"
  308. DATA "Time 1"
  309. DATA "Time 2"
  310. DATA "Date 4"
  311. DATA "Date 5"
  312. DATA "Time 3"
  313. DATA "Time 4"
  314.  
  315. Page3Data:
  316.  
  317. DATA "123-Write default date, time format:"
  318. DATA "    Date, Time format 1:"
  319. DATA "    Date, Time format 2:"
  320. DATA "    Date, Time format 3:"
  321. DATA "    Date, Time format 4:"
  322. DATA "    Date only format 5:"
  323.  
  324. Page5Data:
  325.  
  326. 'The @Function data below is laid out in:
  327. '   123-Write @Function code #,
  328. '   string function descriptor,
  329. '   then col, row numbers (varies by "Page" being written) and then
  330. '   a flag, either 0 or -1 to tell the demo program whether the particular
  331. '      @function is 2.0+ compatible.  (-1 = 2.0+ only)
  332.  
  333. DATA 03,"@ABS",3,42,0,0,0
  334. DATA 04,"@INT",3,42,0,0,0
  335. DATA 17,"@MOD",1,42,2,42,0
  336. DATA 23,"@RAND",0,0,0,0,0
  337. DATA 33,"@ROUND",3,42,2,42,0
  338. DATA 05,"@SQRT",1,44,0,0,0
  339. DATA 16,"@EXP",1,47,0,0,0
  340. DATA 07,"@LN",1,47,0,0,0
  341. DATA 06,"@LOG",1,47,0,0,0
  342.  
  343. DATA 08,"@PI",1,47,0,0,0
  344. DATA 09,"@SIN",1,47,0,0,0
  345. DATA 10,"@COS",1,47,0,0,0
  346. DATA 11,"@TAN",1,47,0,0,0
  347. DATA 15,"@ACOS",1,47,0,0,0
  348. DATA 14,"@ASIN",1,47,0,0,0
  349. DATA 13,"@ATAN",1,47,0,0,0
  350. DATA 12,"@ATAN2",1,47,1,52,-1
  351.  
  352. Page6Data:
  353.  
  354. DATA 51,"@AVG",0,63,5,69,0
  355. DATA 52,"@COUNT",0,63,5,69,0
  356. DATA 54,"@MAX",0,63,5,69,0
  357. DATA 53,"@MIN",0,63,5,69,0
  358. DATA 58,"@STD",0,63,5,69,0
  359. DATA 50,"@SUM",0,63,5,69,0
  360. DATA 57,"@VAR",0,63,5,69,0
  361.  
  362. DATA 62,"@DAVG",0,63,5,69,7,63,7,65,7,66,0
  363. DATA 63,"@DCOUNT",0,63,5,69,7,63,7,65,7,66,0
  364. DATA 65,"@DMAX",0,63,5,69,7,63,7,65,7,66,0
  365. DATA 64,"@DMIN",0,63,5,69,7,63,7,65,7,66,0
  366. DATA 67,"@DSTD",0,63,5,69,7,63,7,65,7,66,0
  367. DATA 61,"@DSUM",0,63,5,69,7,63,7,65,7,66,0
  368. DATA 66,"@DVAR",0,63,5,69,7,63,7,65,7,66,0
  369.  
  370. Page7Data:
  371.  
  372. DATA 59,"@IRR",14,24,11,23,11,24,0,0,0
  373. DATA 56,"@NPV",14,22,11,23,11,37,0,0,0
  374. DATA 26,"@PMT",14,22,14,24,14,26,0,0,0
  375. DATA 27,"@PV",9,24,14,24,14,26,0,0,0
  376. DATA 28,"@FV",9,24,14,24,14,26,0,0,0
  377. DATA 85,"@RATE",9,26,9,25,14,25,0,0,-1
  378. DATA 86,"@TERM",9,24,14,24,9,26,0,0,-1
  379. DATA 87,"@CTERM",14,24,9,26,9,25,0,0,-1
  380. DATA 88,"@SLN",14,28,14,29,14,30,0,0,-1
  381. DATA 90,"@DDB",14,28,14,29,14,30,14,31,-1
  382. DATA 89,"@SYD",14,28,14,29,14,30,14,31,-1
  383.  
  384. Page8Data:
  385.  
  386. DATA 22,"@TRUE",0,0,0,0,0,0,0
  387. DATA 21,"@FALSE",0,0,0,0,0,0,0
  388. DATA 29,"@IF",9,42,12,42,12,43,0
  389. DATA 29,"@IF",9,43,12,42,12,43,0
  390. DATA 02,"@ERR",0,0,0,0,0,0,0
  391. DATA 01,"@NA",0,0,0,0,0,0,0
  392. DATA 20,"@ISERR",9,46,0,0,0,0,0
  393. DATA 20,"@ISERR",9,47,0,0,0,0,0
  394. DATA 19,"@ISNA",9,47,0,0,0,0,0
  395. DATA 19,"@ISNA",9,46,0,0,0,0,0
  396. DATA 38,"@ISNUMBER",9,42,0,0,0,0,-1
  397. DATA 38,"@ISNUMBER",12,42,0,0,0,0,-1
  398. DATA 39,"@ISSTRING",12,42,0,0,0,0,-1
  399. DATA 39,"@ISSTRING",9,42,0,0,0,0,-1
  400.  
  401. Page9Data:
  402.  
  403. DATA 69,"@COLS",0,82,7,86,0,0,0,0,-1
  404. DATA 60,"@HLOOKUP",2,82,0,82,7,86,0,82,-1
  405. DATA 68,"@INDEX",0,82,7,86,2,82,0,82,-1
  406. DATA 70,"@ROWS",0,82,7,86,0,0,0,0,-1
  407. DATA 55,"@VLOOKUP",2,82,0,82,7,86,1,82,-1
  408. DATA 84,"@@(D89)",3,88,0,0,0,0,0,0,-1
  409. DATA 78,"@CELL",4,88,0,4,0,0,0,0,-1
  410. DATA 49,"@CELLPOINTER",5,88,0,4,0,0,0,0,-1
  411.  
  412. Page10Data:
  413.  
  414. DATA "123-Write version 2 demo worksheet                              Page 10"
  415. DATA " "
  416. DATA "   This page is the second page of the 123-Write features index."
  417. DATA " "
  418. DATA "To return to the first index page, hit F5, then F3 and select PAGE_1."
  419. DATA " "
  420. DATA "Additional features of 123-Write are below.  You can use the:"
  421. DATA "F5 [GOTO] key, then the F3 key to select an area of interest.
  422. DATA " "
  423. DATA "Page 10     This page,  Another example of String writes."
  424. DATA "     11     Date and Time @ Functions."
  425. DATA "     12     String handling @ Functions."
  426. DATA "     13     The @Choose function, needs a special CALLing method."
  427. DATA "     14     Examples of the 123-Write lCellMath routine."
  428. DATA "     15     123-Write's lColFunction and lRowFunction routines."
  429. DATA "     16     The lConstMath routine.  Takes a cell and fixed number."
  430. DATA "     17     Multicell math formulas.  Simple math on multiple cells."
  431. DATA "     18     Print control routines, range, borders, margins etc."
  432. DATA "     19     Sort range controls, define and select keys."
  433. DATA "     20     Spreadsheet cell linking, 1-2-3 Release 2.2 only."
  434.  
  435. Page11Data:
  436.  
  437. DATA 31,"@MONTH",14,62,0,0,0,0,0
  438. DATA 30,"@DAY",14,62,0,0,0,0,0
  439. DATA 32,"@YEAR",14,62,0,0,0,0,0
  440. DATA 24,"@DATE",9,64,9,62,9,63,0
  441. DATA 47,"@DATEVALUE",14,64,0,0,0,0,-1
  442. DATA 35,"@HOUR",14,63,0,0,0,0,-1
  443. DATA 36,"@MINUTE",14,63,0,0,0,0,-1
  444. DATA 37,"@SECOND",14,63,0,0,0,0,-1
  445. DATA 34,"@TIME",9,67,9,68,9,69,-1
  446. DATA 48,"@TIMEVALUE",14,65,0,0,0,0,-1
  447. DATA 25,"@NOW",0,0,0,0,0,0,0
  448.  
  449. Page12Data:
  450.  
  451. DATA "These","are","string","entries","in","seperate","cells."
  452. DATA "     This string is contained all in one cell."
  453. DATA 45,"@CODE",8,82,0,0,0,0,-1              : REM all col J (9) row-85
  454. DATA 44,"@CHAR",9,85,0,0,0,0,-1              : REM row-86
  455. DATA 80,"@CLEAN",9,82,0,0,0,0,-1             : REM row-87
  456. DATA 73,"@LOWER",8,82,0,0,0,0,-1             : REM row-88
  457. DATA 72,"@UPPER",8,82,0,0,0,0,-1             : REM row-89
  458. DATA 83,"@EXACT",9,88,9,89,0,0,-1            : REM row-90
  459. DATA 83,"@EXACT",9,88,9,88,0,0,-1            : REM row-91
  460. DATA 46,"@FIND",10,82,8,83,13,81,-1          : REM row-92
  461. DATA 40,"@LENGTH",8,83,0,0,0,0,-1            : REM row-93
  462. DATA 74,"@LEFT",8,83,9,92,0,0,-1             : REM row-94
  463. DATA 43,"@MID",8,83,9,92,9,92,-1             : REM row-95
  464. DATA 75,"@RIGHT",8,83,9,92,0,0,-1            : REM row-96
  465. DATA 77,"@PROPER",8,83,0,0,0,0,-1            : REM row-97
  466. DATA 79,"@TRIM",8,83,0,0,0,0,-1              : REM row-98
  467.  
  468. DATA 71,"@REPEAT",9,86,9,92,0,0,0,0,-1
  469. DATA 76,"@REPLACE",9,98,9,91,9,93,9,87,-1
  470. DATA 42,"@STRING",14,84,9,91,0,0,0,0,-1
  471. DATA 41,"@VALUE",14,83,0,0,0,0,0,0,-1
  472. DATA 82,"@N(O84)",14,83,14,83,0,0,0,0,-1
  473. DATA 82,"@N(O85)",14,84,14,84,0,0,0,0,-1
  474. DATA 81,"@S(O84)",14,83,14,83,0,0,0,0,-1
  475. DATA 81,"@S(O85)",14,84,14,84,0,0,0,0,-1
  476.  
  477. Page13Data:
  478.  
  479. DATA "123-Write version 2 demo worksheet  -- The @CHOOSE function.    Page 13"
  480. DATA " "
  481. DATA "The @CHOOSE function requires a set of parameters different than any"
  482. DATA "other Lotus 1-2-3 @Function.  Where some @Functions take a single cell,"
  483. DATA "a range or even mixed parameters, they all have a pretty rigid format."
  484. DATA " "
  485. DATA "@CHOOSE on the other hand is rather flexible. It takes an integer first,"
  486. DATA "which represents which element of the list to select (Choice below) and"
  487. DATA "a list of individual cells.  Rather than set up a seperate routine for"
  488. DATA "this one function, 123-Write is coded to use the second parameter of an"
  489. DATA "integer structure (either a TYPE'd variable or an array) as the count"
  490. DATA "of cells in the formula. The offset cell must be counted as part of the"
  491. DATA "list.  See the BASIC source code for how this call was set up.  The cell"
  492. DATA "count passed to the routine was 9, eight cells in the list, plus the"
  493. DATA "offset cell."
  494. DATA " "
  495. DATA "Zero","One","Two","Three","Four","Five","Six","Seven"
  496. DATA "Choice:"
  497. DATA "You selected: "
  498.  
  499. Page14Data:
  500.  
  501. DATA "123-Write version 2 demo worksheet  -- The lCellMath routine.   Page 14"
  502. DATA " "
  503. DATA "The lCellMath routine does simple Quick Math on two cells."
  504. DATA "In the call, you specify what two cells to operate on, and"
  505. DATA "the operation to perform.  The operations are:  Add, Subtract"
  506. DATA "Multiply, Divide, and raise to a power."
  507. DATA ""
  508. DATA "R28+S28:"
  509. DATA "R29-S29:"
  510. DATA "R30*S30:"
  511. DATA "R31/S31:"
  512. DATA "R32^S32:"
  513.  
  514. Page15Data:
  515.  
  516. DATA "@SUM(row)",1
  517. DATA "@AVG(row)",2
  518. DATA "@COUNT(row)",3
  519. DATA "@MIN(row)",4
  520. DATA "@MAX(row)",5
  521. DATA "@STD(row)",6
  522. DATA "@VAR(row)",7
  523. DATA "@COLS(row)",8
  524.  
  525. DATA "@SUM(col)",1
  526. DATA "@AVG(col)",2
  527. DATA "@COUNT(col)",3
  528. DATA "@MIN(col)",4
  529. DATA "@MAX(col)",5
  530. DATA "@STD(col)",6
  531. DATA "@VAR(col)",7
  532. DATA "@ROWS(col)",8
  533.  
  534. Page16Data:
  535.  
  536. DATA "123-Write version 2 demo worksheet--The lConstMath routine.    Page 16"
  537. DATA ""
  538. DATA "lConstMath takes a fixed number and a cell reference and writes a"
  539. DATA "simple math formula to the current cell.  The operators you can"
  540. DATA "use are Add, Subtract, Multiply, Divide and raise to a value."
  541. DATA
  542. DATA "If the operator is a negative number, the order of the math is"
  543. DATA "reversed.  For example, with a constant value of: "
  544. DATA "Add P71 and const:"
  545. DATA "Sub const from P72:"
  546. DATA "Multiply P73 by const:"
  547. DATA "Divide P74 and const:"
  548. DATA "Raise P75 to const power:"
  549.  
  550. Page17Data:
  551.  
  552. DATA "123-Write version 2   --    The lMultiCellMath routine.        Page 17"
  553. DATA ""
  554. DATA "lMultiCellMath use an integer structure to perform math on a series of"
  555. DATA "cells.  The array or TYPE'd variable needs to be filled in with the cell"
  556. DATA "to operate on, (two integers, col and row) and the operation to perform."
  557. DATA "The number of cells in the calculation is limited by Lotus's formula"
  558. DATA "length maximum.  The last operation code sent to 123-Write must be a"
  559. DATA "zero to indicate the end of the formula."
  560. DATA ""
  561. DATA "The cells below were written using numeric values from other parts of"
  562. DATA "this worksheet.  Notice how the formula expands from left to right."
  563. DATA "It is important to keep operator precedence in mind when coding too.
  564. DATA ""
  565. DATA 19,70,1,19,51,2,15,43,3,15,45,4,19,48,1,19,54,2,16,44,3,17,45,0
  566.  
  567. Page18Data:
  568.  
  569. DATA "123-Write version 2   --    The lPrint? Routines.              Page 18"
  570. DATA ""
  571. DATA "123-Write allows you complete control over the printed output of your"
  572. DATA "spreadsheets.  The routines available, the Lotus defaults and the new"
  573. DATA "settings, written from BASIC are:"
  574. DATA ""
  575. DATA "                                         Lotus              Current"
  576. DATA "Routine           Effect               Default              Setting"
  577. DATA ""
  578. DATA "lPrintRange       Define print range      none           This page"
  579. DATA "lPrintBorders     Column & Row borders    none     Col A and Row 1"
  580. DATA "lPrintMargins     Page margins*    4-76-2-2-66         2-78-3-3-66"
  581. DATA "lPrintSetup       Printer Setup String    none             ESC-X-1"
  582. DATA "lPrintTitle       Header and Footer       none   'Header'-'Footer'"
  583. DATA ""
  584. DATA "*The margins are defined as Left, Right, Top, Bottom, Page Length"
  585.  
  586. Page19Data:
  587.  
  588. DATA "123-Write version 2   --    The Sort Range Routines.            Page 19"
  589. DATA ""
  590. DATA "123-Write allows you complete control over the sort range defined in"
  591. DATA "your spreadsheet.  Lotus defaults to no defined sort range, so that"
  592. DATA "to build one in 123, you would have to include a macro to define the"
  593. DATA "sort range, keys, ascending or descending order etc.  The routines"
  594. DATA "in 123-Write allow you to determine these settings in advance:"
  595. DATA ""
  596. DATA "                                                            Current"
  597. DATA "Routine           Effect                                    Setting"
  598. DATA ""
  599. DATA "lSortRange        Specifies the range to be sorted.        P43..V50"
  600. DATA "lSortKey          Specifies the primary or secondary       P = V43"
  601. DATA "                    sort key column, & whether sort        S = U43"
  602. DATA "                    is ascending or descending.          both ascnd"
  603. DATA ""
  604. DATA "The defined range is the table on Page 15.  If you [GOTO] page 15,"
  605. DATA "and issue a /Data Sort Go command, you'll see the results."
  606.  
  607. Page20Data:
  608.  
  609. DATA "123-Write version 2   --    The lLink Routine.                   Page 20"
  610. DATA ""
  611. DATA "123-Write allow you to define cells in your worksheets that will contain"
  612. DATA "values from a second worksheet.  This feature, spreadsheet linking, was"
  613. DATA "not available in 1-2-3 releases before 2.2.  Care should be taken before"
  614. DATA "using the routine, to be sure the target system is at least release 2.2."
  615. DATA ""
  616. DATA "lLink requires that you specify a file and cell or range name in the same"
  617. DATA "format as Lotus would use.  Two left angle bracketts, the file name, two"
  618. DATA "right angle brackets and the range name."
  619. DATA ""
  620.  
  621. SUB ColFeed
  622.  
  623.     'Just a routine to stay within a column, in a top down form.
  624.  
  625.     CALL lDown(1)
  626.     CALL lLeft(1)
  627.  
  628. END SUB
  629.  
  630. SUB Page1
  631.  
  632. '==================================================================
  633. '
  634. '  When a worksheet file is opened with lFileOpen, the cell pointer
  635. '  that 123-Write maintains is positioned at A1, which is column 0
  636. '  row 0.
  637. '
  638. '  Next step is to write some string data to the first 'page' of the
  639. '  worksheet.  A page in the default setup is 20 rows vertical and
  640. '  8 cols horizontal, column A thru H, 0 thru 7.  Each column is 9
  641. '  characters wide by default, so we can write strings of up to 72
  642. '  characters onto a page, or 'window'.
  643. '
  644. '  Routines used to write to our first window are:
  645. '    lWriteStr and lLineFeed.
  646. '
  647. '==================================================================
  648.  
  649.     CALL lSetLoc(0, 0)        'Overkill in this instance.
  650.     RESTORE Page1Data         '   Same as above!
  651.     CALL WriteCol(20)         'Writes 20 rows of string data.
  652.  
  653. END SUB
  654.  
  655. SUB Page10
  656.  
  657. '=========================================================================
  658. '
  659. '    Boy, this is boring, just writing a second menu page....
  660. '
  661. '=========================================================================
  662.  
  663.     RESTORE Page10Data
  664.     CALL lSetLoc(Page10Col, Page10Row)
  665.     CALL WriteCol(19)
  666.  
  667. END SUB
  668.  
  669. SUB Page11
  670.  
  671. '=========================================================================
  672. '
  673. '  More cell functions.... These deal with the date and time functions.
  674. '
  675. '=========================================================================
  676.  
  677.     CALL lSetCellForm(fixed, 0)
  678.     CALL lSetLoc(Page11Col, Page11Row)
  679.     CALL lWriteStr("123-Write version 2 Date and Time @ Functions              Page 11", errCode)
  680.     CALL lSetLoc(13, 62)             'Jump over to N63 and write..
  681.     CALL lWriteStr("Today's date:", errCode)
  682.     CALL lToday               'Writes the @Now function with date format.
  683.     CALL lDown(1)
  684.     CALL lLeft(2)
  685.     CALL lWriteStr("Current time:", errCode)
  686.     CALL lTimeNow             'Writes the @Now function with time format.
  687.     CALL lDown(1)
  688.     CALL lLeft(2)
  689.     a$ = DATE$
  690.     MID$(a$, 3, 1) = "/": MID$(a$, 6, 1) = "/"
  691.  
  692.     IF MID$(a$, 7, 2) = "19" THEN
  693.         a$ = LEFT$(a$, 6) + RIGHT$(a$, 2)
  694.     END IF
  695.  
  696.     CALL lWriteStr("Date string:", errCode)
  697.     CALL lWriteStr(CHR$(34) + a$, errCode)    'Right justify.
  698.  
  699.     CALL lDown(1)
  700.     CALL lLeft(2)
  701.     a$ = TIME$
  702.  
  703.     CALL lWriteStr("Time string:", errCode)
  704.     CALL lWriteStr(CHR$(34) + a$, errCode)    'Right justify.
  705.  
  706.     CALL lSetLoc(Page11Col, Page11Row)
  707.     CALL lDown(2)            'set up for routine display.
  708.  
  709.     RESTORE Page11Data
  710.  
  711.     FOR i = 1 TO 10
  712.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, support
  713.         IF i = 9 THEN CALL lSetCellForm(fixed, 4)
  714.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  715.  
  716.         IF support THEN
  717.             IF lVersion THEN
  718.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  719.             ELSE
  720.                 CALL lWriteStr("Not Avail", errCode)
  721.             END IF
  722.         ELSE
  723.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  724.         END IF
  725.  
  726.         CALL lDown(1)
  727.         CALL lLeft(2)
  728.     NEXT i
  729.  
  730.     READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, support
  731.     CALL lSetCellForm(fixed, 2)
  732.     CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  733.  
  734.     IF support THEN
  735.         IF lVersion THEN
  736.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  737.         ELSE
  738.             CALL lWriteStr("Not Avail", errCode)
  739.         END IF
  740.     ELSE
  741.         CALL lCellFunction(VARSEG(f), VARPTR(f))
  742.     END IF
  743.  
  744. END SUB
  745.  
  746. SUB Page12
  747.  
  748. '=========================================================================
  749. '
  750. '  Even more cell functions.... These deal with the string functions.
  751. '
  752. '=========================================================================
  753.  
  754.     CALL lSetLoc(Page12Col, Page12Row)
  755.  
  756.     CALL lWriteStr("123-Write version 2.0 Demonstarion Worksheet--String @Functions Page 12", errCode)
  757.     CALL ColFeed
  758.     CALL lDown(1)
  759.  
  760.     FOR i = 1 TO 7
  761.         READ a$
  762.         CALL lWriteStr(a$, errCode)
  763.     NEXT
  764.  
  765.     CALL lDown(1)
  766.     CALL lLeft(7)
  767.  
  768.     READ a$
  769.     CALL lWriteStr(a$, errCode)
  770.  
  771.     CALL lSetLoc(lCol("n"), 83)
  772.     CALL lWriteStr(CHR$(34) + "A string:", errCode)
  773.     CALL lWriteStr(CHR$(34) + "123.456", errCode)
  774.     CALL ColFeed
  775.     CALL lLeft(1)
  776.     CALL lSetCellForm(fixed, 3)
  777.     CALL lWriteStr(CHR$(34) + "A real #:", errCode)
  778.     CALL lWriteNum(123.456#, errCode)
  779.  
  780.     CALL lSetLoc(lCol("I"), 85)
  781.  
  782.     FOR i = 1 TO 14
  783.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, support
  784.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  785.  
  786.         IF support THEN
  787.             IF lVersion THEN
  788.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  789.             ELSE
  790.                 CALL lWriteStr("Not Avail", errCode)
  791.             END IF
  792.         ELSE
  793.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  794.         END IF
  795.  
  796.         CALL lDown(1)
  797.         CALL lLeft(2)
  798.     NEXT i
  799.  
  800.     CALL lSetLoc(Page12Col + 4, Page12Row + 5)
  801.  
  802.     FOR i = 1 TO 8
  803.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, f.col4, f.row4, support
  804.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  805.  
  806.         IF support THEN
  807.             IF lVersion THEN
  808.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  809.             ELSE
  810.                 CALL lWriteStr("Not Avail", errCode)
  811.             END IF
  812.         ELSE
  813.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  814.         END IF
  815.  
  816.         CALL lDown(1)
  817.         CALL lLeft(2)
  818.     NEXT i
  819.  
  820.  
  821. END SUB
  822.  
  823. SUB Page13
  824.  
  825. '=========================================================================
  826. '
  827. '  Something unique, the @choose function.  This guy requires that the
  828. '  number of cells in the 'list' to choose from be specified.  Note that
  829. '  in version 1a, @choose expects all numeric data to work with... This
  830. '  example uses strings, and thus the 1a 1-2-3 will always return 0 as
  831. '  as a result....
  832. '
  833. '=========================================================================
  834.  
  835.  
  836.     CALL lSetLoc(Page13Col, Page13Row)
  837.     CALL lSetCellForm(fixed, 0)
  838.     CALL WriteCol(16)
  839.  
  840.     FOR i = 1 TO 8
  841.         READ a$
  842.         CALL lWriteStr(a$, errCode)
  843.     NEXT
  844.  
  845.     CALL lLineFeed
  846.     CALL WriteCol(2)
  847.  
  848.     CALL lSetLoc(1, 137)           'B138 has the offset, must be 0 to 7
  849.     a = Rand(0, 7)
  850.     CALL lWriteInt(a, errCode)     'Write the offset.
  851.      
  852. '========================================================================
  853. '
  854. '   The array (could use a TYPE'd variable also) has to be:
  855. '
  856. '     ((# of cells in list) * 2) + 4   elements in size.
  857. '
  858. '   In this case we have 8 cells in the list, so DIM is 1 to 20
  859. '
  860. '========================================================================
  861.  
  862.     REDIM temp%(1 TO 20)
  863.  
  864.     temp%(1) = 18          'The @ function desired, @CHOOSE is 18
  865.     temp%(2) = 9           'Number of elements (cells)+1 for the offset cell.
  866.     temp%(3) = 1           'The offset into the list to choose.  In
  867.     temp%(4) = 137         'cell B138
  868.  
  869.     row = 136              'The list data is across row 137
  870.     col = 0                'from column A through column H
  871.  
  872.     FOR i = 5 TO 20 STEP 2      'Fill the balance of the array:
  873.         temp%(i) = col          'Col 0 thru 7 in elements 5,7,9,11,13,15,17,19
  874.         temp%(i + 1) = row      'Constant row in elements 6,8,10,12,14,16,18,20
  875.         col = col + 1
  876.     NEXT
  877.  
  878.     CALL lSetLoc(2, 138)           'The @Choose function goes into C139
  879.     CALL lCellFunction(VARSEG(temp%(1)), VARPTR(temp%(1)))
  880.  
  881.     ERASE temp%
  882.  
  883. END SUB
  884.  
  885. SUB Page14
  886.  
  887. '=========================================================================
  888. '
  889. '  Simple math functions..
  890. '
  891. '=========================================================================
  892.  
  893.     CALL lSetLoc(Page14Col, Page14Row)
  894.     RESTORE Page14Data
  895.     CALL WriteCol(7)
  896.  
  897.     col = 17      'Set to cell R28
  898.     row = 27
  899.     CALL lSetLoc(col, row)                           '<---- Set the location.
  900.     CALL lSetCellForm(fixed, 2)                      '              |
  901.                                                      '              |
  902.     FOR i = 1 TO 5                                   '              
  903.         CALL lWriteInt(i, errCode)                   'add a column +1
  904.         CALL lWriteInt(i + 1, errCode)               'add a column +1
  905.         READ a$                                      '              
  906.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode) 'add a column +1
  907.         CALL lCellMath(col, row, col + 1, row, i)    'add a column +1
  908.         CALL lDown(1)                                '             ===
  909.         CALL lLeft(4)                                '<-- Return -- 4
  910.         row = row + 1
  911.     NEXT
  912.  
  913. END SUB
  914.  
  915. SUB Page15
  916.  
  917.     CALL lSetLoc(Page15Col, Page15Row)
  918.     CALL lWriteStr("123-Write version 2.0  lColFunction & lRowFunction           Page 15", errCode)
  919.     CALL ColFeed
  920.     CALL lDown(1)
  921.  
  922.     RESTORE Page15Data
  923.  
  924.     FOR row = 1 TO 8
  925.         FOR col = 1 TO 5
  926.             CALL lWriteInt(i, errCode)
  927.             i = i + 1
  928.         NEXT
  929.  
  930.         READ a$, operation
  931.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  932.  
  933.         IF operation < 8 OR lVersion THEN
  934.             CALL lRowFunction(Page15Col, Page15Col + 4, operation)
  935.         ELSE
  936.             CALL lWriteStr("Not supported in 1a", errCode)
  937.         END IF
  938.  
  939.         CALL lDown(1)
  940.         CALL lLeft(7)
  941.     NEXT
  942.  
  943.     CALL lGetLoc(col, lastRow)          'Cell pointer is one row
  944.     lastRow = lastRow - 1               'below the last row of data.
  945.  
  946.     FOR col = 1 TO 7
  947.         CALL lWriteStr("\=", errCode)
  948.     NEXT
  949.  
  950.     CALL lDown(1)
  951.     CALL lLeft(7)
  952.  
  953.     FOR col = 1 TO 8
  954.         READ a$, operation
  955.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  956.         CALL lRight(1)
  957.  
  958.         IF operation < 8 OR lVersion THEN
  959.             CALL lColFunction(lastRow - 7, lastRow, operation)
  960.             CALL lColFunction(lastRow - 7, lastRow, operation)
  961.             CALL lColFunction(lastRow - 7, lastRow, operation)
  962.         ELSE
  963.             CALL lWriteStr("Not supported in 1a", errCode)
  964.             CALL lWriteStr("Not supported in 1a", errCode)
  965.             CALL lWriteStr("Not supported in 1a", errCode)
  966.         END IF
  967.  
  968.         CALL lDown(1)
  969.         CALL lLeft(5)
  970.     NEXT
  971.  
  972.  
  973. END SUB
  974.  
  975. SUB Page16
  976.  
  977.     CALL lSetLoc(Page16Col, Page16Row)
  978.     RESTORE Page16Data
  979.     CALL WriteCol(8)
  980.  
  981.     constant = Rand(1, 5)
  982.     CALL lWriteInt(constant, errCode)
  983.     CALL lRight(3)
  984.     CALL lWriteStr("  Positive     Negative", errCode)
  985.  
  986.     constant# = CDBL(constant)
  987.     CALL ColFeed
  988.     CALL lLeft(4)
  989.     CALL lDown(1)
  990.     row = 70
  991.  
  992.     FOR i = 1 TO 5
  993.         CALL lWriteInt(i, errCode)
  994.         READ a$
  995.         CALL lWriteStr(a$, errCode)
  996.         CALL lRight(2)
  997.         CALL lConstMath(lCol("P"), row, constant#, i)
  998.         CALL lConstMath(lCol("P"), row, constant#, -i)
  999.         row = row + 1
  1000.         CALL lDown(1)
  1001.         CALL lLeft(6)
  1002.     NEXT
  1003.  
  1004.     
  1005.  
  1006. END SUB
  1007.  
  1008. SUB Page17
  1009.  
  1010. '========================================================================
  1011. '
  1012. '   This routine is called after the worksheet file was closed,
  1013. '   then re-opened using lFileAppend.  When a spreadsheet is
  1014. '   opened in "Append" mode, the cell pointer is at the {end}{home}
  1015. '   position of the opened file.  Need to set it to prevent writing
  1016. '   over any data that may be there.
  1017. '
  1018. '========================================================================
  1019.  
  1020.     DIM mm(1 TO 8)  AS MultiMathType
  1021.  
  1022.     CALL lGetLoc(oldEndCol, oldEndRow)
  1023.     PRINT "Just closed and reopened the spreadsheet.  The"
  1024.     PRINT "End-Home (size) of the spreadsheet was Cell ";
  1025.     PRINT CHR$(oldEndCol + 65); LTRIM$(STR$(oldEndRow + 1))
  1026.     PRINT "In case you're curious."
  1027.  
  1028.     CALL lSetLoc(Page17Col, Page17Row)
  1029.     RESTORE Page17Data
  1030.     CALL WriteCol(13)
  1031.  
  1032.     CALL lDown(1)
  1033.  
  1034. '========================================================================
  1035. '
  1036. '   What I want to demonstrate here is how a formula can be built up
  1037. '   by adding data on to the existing structure.
  1038. '
  1039. '========================================================================
  1040.  
  1041.  
  1042.     READ mm(1).col, mm(1).row, mm(1).opr
  1043.  
  1044.     FOR i = 2 TO 8
  1045.         READ mm(i).col, mm(i).row, mm(i).opr
  1046.         hold = mm(i).opr
  1047.         mm(i).opr = 0
  1048.         CALL lMultiCellMath(VARSEG(mm(1)), VARPTR(mm(1)))
  1049.         mm(i).opr = hold
  1050.     NEXT
  1051.  
  1052.  
  1053. END SUB
  1054.  
  1055. SUB Page18
  1056.  
  1057.     CALL lSetLoc(Page18Col, Page18Row)
  1058.     RESTORE Page18Data
  1059.     CALL WriteCol(16)
  1060.  
  1061.     CALL lPrintRange(Page18Col, Page18Row, Page18Col + 6, Page18Row + 19)
  1062.     CALL lPrintBorders(0, 0, 0, 0, 0, 0, 0, 0)
  1063.     CALL lPrintMargins(2, 78, 3, 3, 66)
  1064.     CALL lPrintSetup("\027\088\049")
  1065.     CALL lPrintTitle("Header", -1)
  1066.     CALL lPrintTitle("Footer", 0)
  1067.  
  1068.  
  1069. END SUB
  1070.  
  1071. SUB Page19
  1072.  
  1073.     CALL lSetLoc(Page19Col, Page19Row)
  1074.     RESTORE Page19Data
  1075.     CALL WriteCol(18)
  1076.  
  1077.     CALL lSortRange(15, 42, 21, 49)
  1078.     CALL lSortKey(-1, 21, 42, 21, 49, -1)
  1079.     CALL lSortKey(0, 20, 42, 20, 49, -1)
  1080.  
  1081.  
  1082. END SUB
  1083.  
  1084. SUB Page2
  1085.  
  1086. '==================================================================
  1087. '
  1088. '   Page two will display the format options available
  1089. '   when writing a file from 123-Write.
  1090. '
  1091. '   lSetLoc is used to get to the top of page 2.  lWriteInt is used
  1092. '   to write integer values to the cells, and lSetCellForm is called
  1093. '   to change the display format with each cell written.  lRight is
  1094. '   used as a lazy method to move to column I.
  1095. '
  1096. '   Note that some of the displays are going to require more than the
  1097. '   default 9 characters in the cells.  lSetCol is used to widen
  1098. '   column M to 11, N to 12 and O to 13.  Column P is not going to
  1099. '   visible on screen in Lotus.
  1100. '
  1101. '==================================================================
  1102.  
  1103.     newWidth = 11                      'Width setting of the column.
  1104.  
  1105.     FOR i = lCol%("M") TO lCol%("o")   'Note case isn't significant.
  1106.         CALL lSetCol(i, newWidth)      'desired col, desired width.
  1107.         newWidth = newWidth + 1        'next col, 1 greater than current.
  1108.     NEXT
  1109.  
  1110.     RESTORE Page2Data
  1111.     CALL lSetLoc(Page2Col, Page2Row)   'Position cell pointer for first write.
  1112.     READ a$
  1113.     CALL lWriteStr(a$, errCode)        'print header line
  1114.     IF errCode THEN ERROR 255
  1115.     number = 1                         'what integer we're going to write
  1116.  
  1117.     FOR row = 1 TO 5                   '  "Normal" formats.
  1118.         CALL lLineFeed                 'now at cell A?
  1119.         CALL lRight(8)                 'move to I? (are other ways, but ..)
  1120.         READ a$                        'read & write the description
  1121.         CALL lWriteStr(a$, errCode)    '   of each row
  1122.  
  1123.         FOR col = 0 TO 5
  1124.             CALL lSetCellForm(row, col)       'row equals the format option &
  1125.             CALL lWriteInt(number, errCode)   'col is the # of decimal places
  1126.             IF errCode THEN ERROR 255
  1127.             number = number + 1
  1128.         NEXT
  1129.     NEXT
  1130.  
  1131.     CALL lLineFeed                            'now at cell A?
  1132.     CALL lRight(8)                            'move to I?
  1133.  
  1134.     FOR i = 0 TO 6                            'Slip in a ===== page break.
  1135.         CALL lWriteStr("\=", errCode)         'Note that the repeating
  1136.     NEXT                                      'character label prefix is
  1137.                                               'specified.  Over-rides the
  1138.                                               '123-Write default.
  1139.  
  1140. '==================================================================
  1141. '
  1142. '   At this point the cell pointer is one column to the right, on the same
  1143. '   row as, the last cell written.  Some of the "special" formats take a
  1144. '   little more work (planning) to get them to get them to look 'nice'.
  1145. '
  1146. '   So, because one column to the left of the point we're at now is
  1147. '   13 characters wide, we'll use it to write out the special format options.
  1148. '   Lot of jumping here so see if you can follow the bouncing cursor, err
  1149. '   cell pointer....
  1150. '
  1151. '==================================================================
  1152.  
  1153.     CALL lLeft(5)                 'to O then N then M
  1154.     CALL lDown(2)                 'Skip a couple of lines....
  1155.     CALL lWriteStr("Special Formats:", errCode)     'What we're showing
  1156.     IF errCode THEN ERROR 255
  1157.  
  1158.     CALL lRight(1)                 'Add a column then move up a line
  1159.     CALL lUp(1)
  1160.  
  1161.     IF lVersion THEN maxForm = 12 ELSE maxForm = 5
  1162.  
  1163.     FOR format = 0 TO maxForm             'All but "default"
  1164.         CALL lSetCellForm(1, 0)           'Fixed, 0 decimals to display
  1165.         CALL lWriteInt(format, errCode)   'the 'Special' cell format number.
  1166.         IF errCode THEN ERROR 255
  1167.         READ a$
  1168.         CALL lWriteStr(a$, errCode)       'What format we're showing
  1169.         CALL lSetCellForm(6, format)      'Set cell format to Special, 0 thru
  1170.                                           '   maxForm (maximum special formats)
  1171.         CALL lWriteNum(RND * 10, errCode) 'Throw a number into the cell
  1172.         CALL lLeft(3)                     'Run back to the correct column
  1173.         CALL lDown(1)                     '   and drop down a line.
  1174.     NEXT
  1175.  
  1176. '=========================================================================
  1177. '
  1178. '  OK, that should give us every cell format under the sun.
  1179. '
  1180. '=========================================================================
  1181.  
  1182. END SUB
  1183.  
  1184. SUB Page20
  1185.  
  1186.     CALL lSetLoc(Page20Col, Page20Row)
  1187.     RESTORE Page20Data
  1188.     CALL WriteCol(11)
  1189.  
  1190.     a$ = "CALL lLink(" + CHR$(34) + "<<filename>>Total" + CHR$(34) + ")"
  1191.     CALL lWriteStr(a$, errCode)
  1192.  
  1193. END SUB
  1194.  
  1195. SUB Page3
  1196.  
  1197. '=========================================================================
  1198. '
  1199. '  Page three shows the date and time routines, and the formats available.
  1200. '  Some formats will need need wide columns, so we'll move to column P
  1201. '  and use that area.
  1202. '
  1203. '=========================================================================
  1204.  
  1205.     page3col = lCol%("P")
  1206.     page3row = 0
  1207.     CALL lSetLoc(page3col, page3row)
  1208.     CALL lSetCol(page3col + 4, 11)
  1209.     CALL lSetCol(page3col + 5, 13)
  1210.  
  1211.     CALL lWriteStr("123-Write version 2 demo worksheet                               Page 3", errCode)
  1212.     IF errCode THEN ERROR 255
  1213.  
  1214. '=========================================================================
  1215. '
  1216. '   Another method of moving to a defined place, without left right up
  1217. '   down etc...  which is a starting place for yet another loop!
  1218. '
  1219. '=========================================================================
  1220.  
  1221.     RESTORE Page3Data
  1222.     protected = 0             'will turn individual cell protection off & on.
  1223.  
  1224.     FOR i = 1 TO 5
  1225.         CALL lSetLoc(page3col, (page3row + 1 + i))  'Set the cell pointer
  1226.         READ a$                                     'Read and write the
  1227.         CALL lWriteStr(a$, errCode)                 ' description label.
  1228.         IF errCode THEN ERROR 255
  1229.  
  1230.         CALL lSetLoc(page3col + 4, (page3row + 1 + i))
  1231.         CALL lDate(DATE$)                          'Writes the current date &
  1232.         CALL lTime(TIME$)                          'time in the default
  1233.         CALL lSetDateForm(i, protected)            'formats. Then changes the
  1234.         CALL lSetTimeForm(i, protected)            'cell formats & toggles the
  1235.         protected = NOT protected                  'cell protection.
  1236.     NEXT
  1237.  
  1238.     'do date format 5 by itself, as there is no time format 5.
  1239.  
  1240.     CALL lSetLoc(page3col, (page3row + 1 + i))
  1241.     READ a$
  1242.     CALL lWriteStr(a$, errCode)
  1243.     IF errCode THEN ERROR 255
  1244.  
  1245.     CALL lSetLoc(page3col + 4, page3row + 1 + i)
  1246.     CALL lDate(DATE$)
  1247.  
  1248.     'Skip a couple of rows, I have no idea where I am now. But it's
  1249.     'a starting place.
  1250.  
  1251.     CALL lSetLoc(page3col, (page3row + 3 + i))
  1252.     CALL lWriteStr("Setting of a date format and time format has no effect on other", errCode)
  1253.     ColFeed
  1254.     CALL lWriteStr("cells written with lWriteNum,  lWriteInt or lWriteStr.   It's a", errCode)
  1255.     ColFeed
  1256.     CALL lWriteStr("convience to set it for calls to the lDate, lTime, lTimeNow and", errCode)
  1257.     ColFeed
  1258.     CALL lWriteStr("lToday routines.  lDate & lTime were used above, using the sys-", errCode)
  1259.     ColFeed
  1260.     CALL lWriteStr("tem date and time.  Below are the lToday and lTimeNow routines.", errCode)
  1261.     ColFeed
  1262.     CALL lDown(2)
  1263.     CALL lSetDateForm(4, 1)
  1264.     CALL lWriteStr("lToday routine:", errCode)
  1265.     CALL lRight(2)
  1266.     CALL lToday
  1267.     CALL lDown(1)
  1268.     CALL lLeft(4)
  1269.     CALL lSetTimeForm(3, 1)
  1270.     CALL lWriteStr("lTimeNow routine:", errCode)
  1271.     CALL lRight(2)
  1272.     CALL lTimeNow
  1273.     CALL lDown(1)
  1274.     CALL lLeft(4)
  1275.     CALL lWriteStr("Hit F9 now" + STRING$(17, "-") + "^", errCode)
  1276.  
  1277. END SUB
  1278.  
  1279. SUB Page4
  1280.  
  1281. '=========================================================================
  1282. '
  1283. '   Got a little carried away with page 3....
  1284. '
  1285. '   What to do with page 4?  Well, let's start work on the Boolean functions.
  1286. '   The manual page for lBoolean should be near by, I know mine is... Having
  1287. '   it handy will aid in tracing along.....
  1288. '
  1289. '   Old hat to start.  We'll use A21 as the upper left corner of page 4, and
  1290. '   we need to set the cell format for numeric stuff to what we want.  Have
  1291. '   no idea what it currently is, it's whatever the last special format we
  1292. '   displayed???  Will use fixed, 3.
  1293. '
  1294. '=========================================================================
  1295.  
  1296.     CALL lSetCellForm(fixed, 3)
  1297.     CALL lSetLoc(0, 20)
  1298.     CALL lWriteStr("123-Write version 2 boolean comparison examples.                 Page 4", errCode)
  1299.     CALL lLineFeed
  1300.     CALL lLineFeed
  1301.  
  1302.     CALL lWriteStr("Data:", errCode)                   'Just write a series
  1303.     FOR i = 0 TO 6: CALL lWriteInt(i, errCode): NEXT   'of integers for data
  1304.     CALL lLineFeed                         'Skipping a line.  The left bound
  1305.     CALL lLineFeed                         'of this page is col A, lLinefeed
  1306.                                            'will suffice
  1307.  
  1308.     CALL lWriteStr("B23=C23:", errCode)
  1309.     CALL lBoolean(1, 22, 2, 22, 1)               'operation=1, equal?
  1310.     CALL lRight(1)
  1311.     CALL lWriteStr("B23=B24:", errCode)
  1312.     CALL lBoolean(1, 22, 1, 23, 1)               'operation=1, equal?
  1313.     CALL lWriteStr("<---Equality", errCode)
  1314.     CALL lLineFeed
  1315.  
  1316.     CALL lWriteStr("B23<>C23:", errCode)
  1317.     CALL lBoolean(1, 22, 2, 22, 2)               'operation=2, not equal?
  1318.     CALL lRight(1)
  1319.     CALL lWriteStr("B23<>B24:", errCode)
  1320.     CALL lBoolean(1, 22, 1, 23, 2)               'operation=2, not equal?
  1321.     CALL lWriteStr("<--Not equal", errCode)
  1322.     CALL lLineFeed
  1323.  
  1324.     CALL lWriteStr("B23<=C23:", errCode)
  1325.     CALL lBoolean(1, 22, 2, 22, 3)               'operation=3, less than
  1326.     CALL lRight(1)                               '              or equal?
  1327.     CALL lWriteStr("C23<=B23:", errCode)
  1328.     CALL lBoolean(2, 22, 1, 22, 3)
  1329.     CALL lWriteStr("<--Less than or equal", errCode)
  1330.     CALL lLineFeed
  1331.  
  1332.     CALL lWriteStr("B23>=C23:", errCode)
  1333.     CALL lBoolean(1, 22, 2, 22, 4)               'operation=4, greater than
  1334.     CALL lRight(1)                               '              or equal?
  1335.     CALL lWriteStr("C23>=B23:", errCode)
  1336.     CALL lBoolean(2, 22, 1, 22, 4)
  1337.     CALL lWriteStr("<--Greater than or equal", errCode)
  1338.     CALL lLineFeed
  1339.  
  1340.     CALL lWriteStr("B23<C23:", errCode)
  1341.     CALL lBoolean(1, 22, 2, 22, 5)               'operation=5, less than?
  1342.     CALL lRight(1)
  1343.     CALL lWriteStr("C23<C23:", errCode)          'Note that this does
  1344.     CALL lBoolean(2, 22, 2, 22, 5)               'not give a "CIRC" error.
  1345.     CALL lWriteStr("<--Less than", errCode)      'which I find odd.....
  1346.     CALL lLineFeed
  1347.  
  1348.     CALL lWriteStr("B23>C23:", errCode)
  1349.     CALL lBoolean(1, 22, 2, 22, 6)               'operation=6, greater than?
  1350.     CALL lRight(1)
  1351.     CALL lWriteStr("C23>B23:", errCode)
  1352.     CALL lBoolean(2, 22, 1, 22, 6)
  1353.     CALL lWriteStr("<--Greater than", errCode)
  1354.     CALL lLineFeed
  1355.  
  1356.     CALL lWriteStr("#AND# :", errCode)           'operation=7, AND
  1357.     CALL lBoolean(1, 22, 2, 22, 7)               'B23 and C23 (0 and 1) = 0
  1358.     CALL lBoolean(2, 22, 3, 22, 7)               'C23 and D23 (1 and 2) = 1
  1359.     CALL lBoolean(1, 22, 1, 23, 7)               'B23 and B24 (0 and 0) = 0
  1360.     CALL lBoolean(3, 22, 3, 23, 7)               'D23 and D24 (2 and 0) = 0
  1361.     CALL lWriteStr("Both cells must be non 0", errCode)
  1362.     CALL lLineFeed
  1363.  
  1364.  
  1365.     CALL lWriteStr("#OR# :", errCode)            'operation=8, OR
  1366.     CALL lBoolean(1, 22, 2, 22, 8)               'B23 and C23 (0 or 1) = 1
  1367.     CALL lBoolean(2, 22, 3, 22, 8)               'C23 and D23 (1 or 2) = 1
  1368.     CALL lBoolean(1, 22, 1, 23, 8)               'B23 and B24 (0 or 0) = 0
  1369.     CALL lBoolean(3, 22, 3, 23, 8)               'D23 and D24 (2 or 0) = 1
  1370.     CALL lWriteStr("One cell must be non 0", errCode)
  1371.     CALL lLineFeed
  1372.  
  1373.     CALL lWriteStr("#NOT# :", errCode)          'operation=9, NOT 1 operator.
  1374.     CALL lBoolean(1, 22, 0, 0, 9)               'B23 (not 0) = 1
  1375.     CALL lBoolean(2, 22, 0, 0, 9)               'C23 (not 1) = 0
  1376.     CALL lBoolean(3, 22, 0, 0, 9)               'D23 (not 2) = 0
  1377.     CALL lBoolean(4, 22, 0, 0, 9)               'E23 (not 3) = 0
  1378.     CALL lWriteStr("If cell is 0, returns 1", errCode)
  1379.     CALL lLineFeed
  1380.     CALL lLineFeed
  1381.  
  1382.     CALL lWriteStr("Note that Lotus uses 1 to indicate a TRUE condition,", errCode)
  1383.     CALL lLineFeed
  1384.     CALL lWriteStr("unlike BASIC which uses a -1 (a true NOT 0, 0 being", errCode)
  1385.     CALL lLineFeed
  1386.     CALL lWriteStr("false?)  Also the AND, OR and NOT operators are not", errCode)
  1387.     CALL lLineFeed
  1388.     CALL lWriteStr("bitwise operators, they just test for zero conditions.", errCode)
  1389.  
  1390. END SUB
  1391.  
  1392. SUB Page5
  1393.  
  1394. '=========================================================================
  1395. '
  1396. '  What's next?  lCellFunction!  Let's get the monster out of the way.
  1397. '
  1398. '  First, remember seeing a TYPE at the start of the program?  If not,
  1399. '  refresh yourself on it, cause that's what we're going to use.  Also
  1400. '  will slip in a column of numbers to work on over in column Z
  1401. '
  1402. '=========================================================================
  1403.  
  1404.     CALL lSetLoc(Page5Col, Page5Row)         'Column is A so...
  1405.     CALL lWriteStr("123-Write ver 2 General, Logarithmic & Trigonomteric @Functions:  Pg 5", errCode)
  1406.     CALL lLineFeed                           'A simple method for skipping
  1407.     CALL lLineFeed                           'a line.
  1408.     CALL lWriteStr("DATA:", errCode)
  1409.     CALL lSetCellForm(fixed, zero)           'what's zero equate to?
  1410.     CALL lWriteInt(11, errCode)              'Cell B43
  1411.     CALL lWriteInt(3, errCode)               'Cell C43
  1412.     CALL lSetCellForm(fixed, 4)
  1413.     a# = CDBL(Rand(1, 8) * 123.45678#)       'a real number to work with
  1414.     CALL lWriteNum(a#, errCode)              'in D43
  1415.     CALL lLineFeed
  1416.     CALL lLineFeed
  1417.     CALL lGetLoc(col, startRow)              'Save row for a millisecond....
  1418.     CALL lSetCellForm(fixed, 4)
  1419.  
  1420.     RESTORE Page5Data
  1421.  
  1422.     FOR i = 1 TO 9                           'Support, if non-zero indicates
  1423.                                              'a release 2.0+ @function....
  1424.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, support
  1425.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  1426.  
  1427.         IF support THEN
  1428.             IF lVersion THEN       'embedding the address calc in the call,
  1429.                 CALL lCellFunction(VARSEG(f), VARPTR(f)) 'cause I'm a chicken.
  1430.             ELSE
  1431.                 CALL lWriteStr("Not Avail", errCode)     'Not supported in 1a.
  1432.             END IF
  1433.         ELSE
  1434.             CALL lCellFunction(VARSEG(f), VARPTR(f))     'All releases.
  1435.         END IF
  1436.  
  1437.         CALL lLineFeed
  1438.     NEXT
  1439.  
  1440.     CALL lSetLoc(3, startRow)                    'Do trig items down Col D
  1441.  
  1442.     FOR i = 1 TO 8
  1443.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, support
  1444.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  1445.  
  1446.         IF support THEN
  1447.             IF lVersion THEN
  1448.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  1449.             ELSE
  1450.                 CALL lWriteStr("Not Avail", errCode)
  1451.             END IF
  1452.         ELSE
  1453.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  1454.         END IF
  1455.  
  1456.         CALL lDown(1)
  1457.         CALL lLeft(2)
  1458.     NEXT
  1459.  
  1460. END SUB
  1461.  
  1462. SUB Page6
  1463.  
  1464. '=========================================================================
  1465. '
  1466. '   Page 6 is the statistical and database statistical page.
  1467. '
  1468. '=========================================================================
  1469.  
  1470.     CALL lSetLoc(Page6Col, Page6Row)
  1471.     CALL lWriteStr("123-Write ver 2 Statistical and Database Statistical @Functions: Pg 6", errCode)
  1472.     CALL lLineFeed
  1473.     CALL lLineFeed
  1474.  
  1475.     FOR i = 0 TO 5
  1476.         CALL lWriteStr("WEEK" + STR$(i), errCode)
  1477.     NEXT
  1478.  
  1479.     CALL lWriteStr("Offset:", errCode)
  1480.     CALL ColFeed
  1481.     CALL lRight(1)
  1482.     CALL lWriteInt(0, errCode)
  1483.     CALL ColFeed
  1484.     CALL lLeft(1)
  1485.     CALL lWriteStr("Criteria Range:", errCode)
  1486.     CALL ColFeed
  1487.     CALL lRight(1)
  1488.     CALL lWriteStr("WEEK 0", errCode)
  1489.  
  1490.     CALL lLineFeed
  1491.     CALL lUp(3)
  1492.  
  1493.     FOR row = 63 TO 69
  1494.         FOR col = 0 TO 5
  1495.             a = Rand(1, 15)
  1496.             b = Rand(1, 15)
  1497.             a# = CDBL(a + (a / b))
  1498.             CALL lWriteNum(a#, errCode)
  1499.         NEXT col
  1500.         CALL lLineFeed
  1501.     NEXT
  1502.  
  1503.     CALL lLineFeed
  1504.     CALL lWriteStr("Statistical:", errCode)
  1505.     CALL lRight(2)
  1506.     CALL lWriteStr("Database Statistical:", errCode)
  1507.  
  1508.     CALL lLineFeed
  1509.     CALL lLineFeed
  1510.  
  1511.     CALL lGetLoc(col, startRow)              'Save row for a bit
  1512.     CALL lSetCellForm(fixed, 4)
  1513.  
  1514.     RESTORE Page6Data
  1515.  
  1516.     FOR i = 1 TO 7
  1517.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, support
  1518.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  1519.  
  1520.         IF support THEN
  1521.             IF lVersion THEN
  1522.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  1523.             ELSE
  1524.                 CALL lWriteStr("Not Avail", errCode)
  1525.             END IF
  1526.         ELSE
  1527.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  1528.         END IF
  1529.  
  1530.         CALL lLineFeed
  1531.     NEXT
  1532.  
  1533.     CALL lSetLoc(3, startRow)                    'Do DB items down Col D
  1534.  
  1535.     FOR i = 1 TO 7
  1536.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, f.col4, f.row4, f.col5, f.row5, support
  1537.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  1538.  
  1539.         IF support THEN
  1540.             IF lVersion THEN
  1541.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  1542.             ELSE
  1543.                 CALL lWriteStr("Not Avail", errCode)
  1544.             END IF
  1545.         ELSE
  1546.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  1547.         END IF
  1548.  
  1549.         CALL lDown(1)
  1550.         CALL lLeft(2)
  1551.     NEXT
  1552.  
  1553. END SUB
  1554.  
  1555. SUB Page7
  1556.  
  1557. '=========================================================================
  1558. '
  1559. '  Page 7 will be the Financial and Accounting functions. Starts in I20
  1560. '
  1561. '=========================================================================
  1562.  
  1563.     CALL lSetLoc(Page7Col, Page7Row)
  1564.     CALL lWriteStr("123-Write ver 2 Financial and Accounting @Functions:      Page 7", errCode)
  1565.     CALL ColFeed
  1566.     CALL ColFeed
  1567.     CALL lRight(4)
  1568.     CALL lWriteStr("Cash Flows", errCode)
  1569.     CALL lRight(1)
  1570.  
  1571.     CALL lWriteStr("Principal:", errCode)
  1572.     CALL ColFeed
  1573.     CALL lWriteStr("Interest:", errCode)
  1574.     CALL ColFeed
  1575.     CALL lWriteStr("Monthly:", errCode)
  1576.     CALL ColFeed
  1577.     CALL lWriteStr("Term Years:", errCode)
  1578.     CALL ColFeed
  1579.     CALL lWriteStr("Term Month:", errCode)
  1580.     CALL ColFeed
  1581.     CALL lDown(1)
  1582.     CALL lWriteStr("Cost:", errCode)
  1583.     CALL ColFeed
  1584.     CALL lWriteStr("Salvage:", errCode)
  1585.     CALL ColFeed
  1586.     CALL lWriteStr("Life:", errCode)
  1587.     CALL ColFeed
  1588.     CALL lWriteStr("Period:", errCode)
  1589.  
  1590.     CALL lSetLoc(Page7Col + 6, Page7Row + 2)
  1591.     CALL lSetCellForm(currcy, 2)
  1592.  
  1593.     CALL lWriteNum(CDBL(Rand(1, 10000)), errCode)
  1594.     CALL ColFeed
  1595.     CALL lSetCellForm(percent, 2)
  1596.  
  1597.     interest# = CDBL(Rand(1, 12) / 100#)
  1598.     CALL lWriteNum(interest#, errCode)
  1599.     CALL ColFeed
  1600.     CALL lWriteNum(interest# / 12#, errCode)
  1601.     CALL ColFeed
  1602.     CALL lSetCellForm(comma, 2)
  1603.     a = Rand(1, 30)
  1604.     CALL lWriteInt(a, errCode)
  1605.     CALL ColFeed
  1606.     CALL lWriteInt(a * 12, errCode)
  1607.     CALL ColFeed
  1608.     CALL lDown(1)
  1609.  
  1610.     cost# = CDBL(Rand(1, 32760))
  1611.     salvage# = CDBL(Rand(1, 1000))
  1612.  
  1613.     IF cost# < salvage# THEN SWAP cost#, salvage#
  1614.     CALL lWriteNum(cost#, errCode)
  1615.     CALL ColFeed
  1616.     CALL lWriteNum(salvage#, errCode)
  1617.     CALL ColFeed
  1618.     life = Rand(10, 20)
  1619.     CALL lWriteInt(life, errCode)
  1620.     CALL ColFeed
  1621.     period = Rand(1, life)
  1622.     CALL lWriteInt(period, errCode)
  1623.  
  1624.     CALL lSetLoc(Page7Col, Page7Row)
  1625.     CALL lRight(3)
  1626.     CALL lDown(3)
  1627.     flow# = CDBL(Rand(1, 9) * 123#)
  1628.     incr# = CDBL(Rand(1, 9) * 12.3#)
  1629.  
  1630.     FOR i = 1 TO 15
  1631.         CALL lWriteNum(flow#, errCode)
  1632.         flow# = flow# + incr#
  1633.         CALL ColFeed
  1634.     NEXT
  1635.  
  1636.     CALL lSetLoc(Page7Col, Page7Row)
  1637.     CALL lDown(2)
  1638.     RESTORE Page7Data
  1639.  
  1640.     FOR i = 1 TO 11
  1641.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, f.col4, f.row4, support
  1642.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  1643.  
  1644.         IF support THEN
  1645.             IF lVersion THEN
  1646.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  1647.             ELSE
  1648.                 CALL lWriteStr("Not Avail", errCode)
  1649.             END IF
  1650.         ELSE
  1651.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  1652.         END IF
  1653.  
  1654.         CALL lDown(1)
  1655.         CALL lLeft(2)
  1656.     NEXT i
  1657.  
  1658. END SUB
  1659.  
  1660. SUB Page8
  1661.  
  1662. '=========================================================================
  1663. '
  1664. '  Page 8 will be the logical functions and the @ERR and @NA functions.
  1665. '
  1666. '=========================================================================
  1667.  
  1668.     CALL lSetLoc(Page8Col, Page8Row)
  1669.     CALL lWriteStr("123-Write version 2 Logical @ Functions                   Page 8", errCode)
  1670.     CALL ColFeed
  1671.     CALL ColFeed                               'Skipping a line in a column.
  1672.     CALL lRight(5)
  1673.     CALL lWriteStr("That's true!", errCode)
  1674.     CALL ColFeed
  1675.     CALL lWriteStr("That's false!", errCode)
  1676.     CALL lSetLoc(Page8Col, Page8Row)
  1677.     CALL lDown(2)
  1678.  
  1679.     RESTORE Page8Data
  1680.  
  1681.     FOR i = 1 TO 14
  1682.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, support
  1683.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  1684.  
  1685.         IF support THEN
  1686.             IF lVersion THEN
  1687.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  1688.             ELSE
  1689.                 CALL lWriteStr("Not Avail", errCode)
  1690.             END IF
  1691.         ELSE
  1692.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  1693.         END IF
  1694.  
  1695.         CALL lDown(1)
  1696.         CALL lLeft(2)
  1697.     NEXT i
  1698.  
  1699. END SUB
  1700.  
  1701. SUB Page9
  1702.  
  1703. '=========================================================================
  1704. '
  1705. '  Page 9 will be range functions.
  1706. '
  1707. '=========================================================================
  1708.  
  1709.     CALL lSetLoc(Page9Col, Page9Row)
  1710.     CALL lWriteStr("123-Write version 2 Range @ Functions                     Page 9", errCode)
  1711.     CALL lLeft(1)
  1712.     CALL lDown(2)
  1713.     i = 1
  1714.  
  1715.     FOR row = 1 TO 5
  1716.         FOR col = 0 TO 7
  1717.             CALL lWriteInt(i, errCode)
  1718.             i = i + 1
  1719.         NEXT
  1720.         CALL lLineFeed
  1721.     NEXT
  1722.  
  1723.     RESTORE Page9Data
  1724.     CALL lLineFeed
  1725.     CALL lWriteStr("A target cell as a string:", errCode)
  1726.     CALL lRight(2)
  1727.     CALL lWriteStr("A5", errCode)
  1728.     CALL lWriteStr("PREFIX", errCode)
  1729.     CALL lWriteStr("CONTENTS", errCode)
  1730.     CALL lLineFeed
  1731.     CALL lLineFeed
  1732.  
  1733.     FOR i = 1 TO 8
  1734.         READ f.fCode, a$, f.col1, f.row1, f.col2, f.row2, f.col3, f.row3, f.col4, f.row4, support
  1735.         CALL lWriteStr(CHR$(34) + a$ + ":", errCode)
  1736.  
  1737.         IF support THEN
  1738.             IF lVersion THEN
  1739.                 CALL lCellFunction(VARSEG(f), VARPTR(f))
  1740.             ELSE
  1741.                 CALL lWriteStr("Not Avail", errCode)
  1742.             END IF
  1743.         ELSE
  1744.             CALL lCellFunction(VARSEG(f), VARPTR(f))
  1745.         END IF
  1746.  
  1747.         CALL lDown(1)
  1748.         CALL lLeft(2)
  1749.     NEXT i
  1750.  
  1751. END SUB
  1752.  
  1753. FUNCTION Rand% (lowerbound, upperbound)
  1754.  
  1755.     'Yes sir, straight from the on-line help window:
  1756.  
  1757.     Rand% = INT((upperbound - lowerbound + 1) * RND + lowerbound)
  1758.  
  1759. END FUNCTION
  1760.  
  1761. SUB WriteCol (count)
  1762.  
  1763.     FOR i = 1 TO count
  1764.         READ a$
  1765.         CALL lWriteStr(a$, errCode)
  1766.         IF errCode THEN ERROR 255
  1767.         CALL ColFeed
  1768.     NEXT
  1769.  
  1770. END SUB
  1771.  
  1772. SUB WriteRanges
  1773.  
  1774.     page3col = lCol%("P")
  1775.     page3row = 0
  1776.  
  1777.     CALL lRange("PAGE_1", Page1Col, Page1Row, Page1Col + 7, Page1Row + 19)
  1778.     CALL lRange("PAGE_2", Page2Col, Page2Row, Page2Col, Page2Row)
  1779.     CALL lRange("PAGE_3", page3col, page3row, page3col, page3row)
  1780.     CALL lRange("PAGE_4", 0, 20, 7, 39)
  1781.     CALL lRange("PAGE_5", Page5Col, Page5Row, Page5Col, Page5Row)
  1782.     CALL lRange("PAGE_6", Page6Col, Page6Row, Page6Col, Page6Row)
  1783.     CALL lRange("PAGE_7", Page7Col, Page7Row, Page7Col, Page7Row)
  1784.     CALL lRange("PAGE_8", Page8Col, Page8Row, Page8Col, Page8Row)
  1785.     CALL lRange("PAGE_9", Page9Col, Page9Row, Page9Col, Page9Row)
  1786.     CALL lRange("PAGE_10", Page10Col, Page10Row, Page10Col + 7, Page10Row + 19)
  1787.     CALL lRange("PAGE_11", Page11Col, Page11Row, Page11Col, Page11Row)
  1788.     CALL lRange("PAGE_12", Page12Col, Page12Row, Page12Col, Page12Row)
  1789.     CALL lRange("PAGE_13", Page13Col, Page13Row, Page13Col, Page13Row)
  1790.     CALL lRange("PAGE_14", Page14Col, Page14Row, Page14Col, Page14Row)
  1791.     CALL lRange("PAGE_15", Page15Col, Page15Row, Page15Col, Page15Row)
  1792.     CALL lRange("PAGE_16", Page16Col, Page16Row, Page16Col, Page16Row)
  1793.     CALL lRange("PAGE_17", Page17Col, Page17Row, Page17Col, Page17Row)
  1794.     CALL lRange("PAGE_18", Page18Col, Page18Row, Page18Col, Page18Row)
  1795.     CALL lRange("PAGE_19", Page19Col, Page19Row, Page19Col, Page19Row)
  1796.     CALL lRange("PAGE_20", Page20Col, Page20Row, Page20Col, Page20Row)
  1797.  
  1798. END SUB
  1799.  
  1800.